package xfsale.service.impl.j2ee;

import java.sql.Connection;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

@SuppressWarnings("unused")
public final class PubConn {

	private static DataSource ds;

	static {
		//创建数据源
		try {
			Context ctx = new InitialContext();
			ds = (DataSource) ctx.lookup("java:comp/env/jdbc/xfsale");
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	//获取数据库连接
	public static Connection getConnection() {
		try {
			return ds.getConnection();
		} catch (Exception e) {
			System.out.println(e);
		}

		return null;
	}
}
